#!/bin/sh -vx
# $Id$
# Copyright 2020 Karl Berry <tex-live@tug.org>
# You may freely use, modify and/or distribute this file.
# 
# Test nul (zero) bytes in texmf.cnf.

BinDir=${BinDir:-.}
ExeExt=${ExeExt:-}
_kpsewhich=$BinDir/kpsewhich$ExeExt

cnf_dir=cnfnull
cnf_file=$cnf_dir/texmf.cnf

# Create the texmf.cnf dynamically so we don't have to check in a file
# containing nul bytes.
rm -rf $cnf_dir
mkdir $cnf_dir
test -d $cnf_dir || exit 1
printf 'x\0=1\n\0' >$cnf_file || exit 2

val=`$_kpsewhich "--cnf-line=TEXMFCNF=$cnf_dir" --var-value=x`
if [ "$ExeExt" = ".exe" ]; then val=`echo $val | sed -e 's/\\r//'`; fi
test x"$val" = x1 || exit 3

# Before we dropped nul bytes in 2020, kpse gave a warning:
#   warning: cnfnull/texmf.cnf:1: (kpathsea) No cnf value on line: x.
# and did not assign anything (since the string ended with the x).
